package org.batch.entity;

import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;

import static java.math.BigDecimal.ZERO;

/**
 * Trading实体类
 *
 * @author LiKun
 * @date 2021/9/27 11:18
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@TableName("trading")
@ApiModel("交易相关实体类")
public class Trading implements Serializable {

    @TableId
    @ApiModelProperty(name = "id", notes = "主键ID")
    private String id;

    @ApiModelProperty(name = "account", notes = "账户ID")
    private String account;

    @ApiModelProperty(name = "tradeAmount", notes = "交易金额")
    private BigDecimal tradeAmount;

    @JsonFormat(pattern = "yyyy-MM-dd hh:mm:ss")
    @ApiModelProperty(name = "createTime", notes = "交易时间")
    private Date tradeTime;

    @ApiModelProperty(name = "effective", notes = "有效标识")
    private String effectFlag;

    /**
     * 获取默认的 {@link Trading} 对象
     *
     * @param <T> 泛型
     *
     * @return 结果
     */
    public static <T extends Trading> T getInstance() {
        return (T) Trading.builder().tradeAmount(ZERO).build();
    }

}
